package com.wsoft.form.controller;

import com.wsoft.core.exception.Asserts;
import com.wsoft.form.dto.TestDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wsoft.response.ResponsePage;
import com.wsoft.response.ResponseResult;

import javax.validation.Valid;
import java.util.ArrayList;

/**
 * 功能描述
 *
 * @author: juiet
 * @date: 2024年08月23日 16:58
 */
@RestController
@Tag(name = "表单测试")
@RequestMapping("/pub/form/test")
public class TestFormController {

    @Operation(summary = "表单测试1",description = "测试描述1")
    @ApiResponse(responseCode = "200", description = "OK")
    @PostMapping("/test1")
    public ResponseResult test(@RequestBody @Valid TestDTO dto) {
        return ResponseResult.success("[test]");
    }


    @Operation(summary = "表单测试2",description = "测试描述2")
    @ApiResponse(responseCode = "200", description = "OK")
    @PostMapping("/test2")
    public ResponsePage test2(@RequestBody @Valid TestDTO dto) {
        return ResponsePage.restPage(new ArrayList<>());
    }


    @Operation(summary = "表单测试3",description = "测试描述2")
    @ApiResponse(responseCode = "200", description = "OK")
    @PostMapping("/test3")
    public ResponsePage test3(@RequestBody @Valid TestDTO dto) {
        Asserts.fail("1212");
        return ResponsePage.restPage(new ArrayList<>());
    }

}
